import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/models/evaluation/benchmarkSkillChartData.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:syncfusion_flutter_charts/charts.dart';

class BenchmarkSkillBarChart extends StatelessWidget {
  BenchmarkSkillBarChart({Key? key, required this.skillChartdata})
      : super(key: key);
  final List<BenchmarkSkillChartData> skillChartdata;
  @override
  Widget build(BuildContext context) {
    Log.debug('build benchmark skill chart');
    TooltipBehavior _tooltipbehavior = TooltipBehavior(enable: true);
    return SfCartesianChart(
        title: ChartTitle(
          alignment: ChartAlignment.near,
          text: 'Skills'.tr,
          textStyle: TextStyle(
              fontFamily: 'Montserrat',
              color: Get.isDarkMode
                  ? Get.theme.primaryColorDark
                  : Get.theme.primaryColorLight),
        ),
        legend: Legend(
          isVisible: false,
          textStyle: TextStyle(
              fontFamily: 'Montserrat',
              color: Get.isDarkMode
                  ? Get.theme.primaryColorDark
                  : Get.theme.primaryColorLight),
        ),
        primaryXAxis: CategoryAxis(),
        primaryYAxis: NumericAxis(minimum: 0, maximum: 100, interval: 10),
        tooltipBehavior: _tooltipbehavior,
        series: <ChartSeries<BenchmarkSkillChartData, String>>[
          ColumnSeries<BenchmarkSkillChartData, String>(
              dataSource: skillChartdata,
              xValueMapper: (BenchmarkSkillChartData data, _) => data.item,
              yValueMapper: (BenchmarkSkillChartData data, _) => data.summary,
              name: 'Skills',
              animationDuration: 1000,
              width: 0.5,
              spacing: 0.5,
              borderRadius: BorderRadius.all(Radius.circular(15)),
              trendlines: <Trendline>[
                Trendline(type: TrendlineType.linear, color: Colors.red)
              ]),
        ]);
  }
}
